
#ifndef __ACQUIRE_CLIENT_PRIVATE_H
#define __ACQUIRE_CLIENT_PRIVATE_H

#include "db/KeyDB.h"
#include <apr_pools.h>

#include "iface/APRInterface.h"
#include "iface/LibSSH2Interface.h"
#include "iface/SSLInterface.h"
#include "iface/SQLiteInterface.h"
#include "db/KeyDB.h"
#include "resolver/Resolver.h"

#include "net/BrokerMessage.h"

typedef struct acquire_common_global_state
{
   APRInterface *apr_iface;
   SSLInterface *ssl_iface;
   LibSSH2Interface *ssh2_iface;
   SQLiteInterface *sqlite_iface;
   KeyDB *keydb;
   Resolver *resolver;
   const char *operational_recipientkeyname;
   const char *operational_senderkeyname;
   const char *my_name;
   const char *password;
   const char *hostname;
   int portno;
   apr_pool_t *mp;
   int registration_state;
} acquireCommonGlobalState;

extern acquireCommonGlobalState state;

void importKeyToDatabase(KeyDB *keydb, const char *keyrealtype, const char *keyname,
   const char *filename, apr_pool_t *t_mp, int docommit);

int exchangeMessage(BrokerMessage &bmsg, apr_pool_t *imp, int *cancel);

#define SERVER_DO_NOTHING                0
#define SERVER_REPLACE_BLOCK_COUNT       1
#define SERVER_ADD_TO_BLOCK_COUNT        2
#define SERVER_SUBTRACT_FROM_BLOCK_COUNT 3

int acquireModifyBlocks(int modifier_done, int delta_done, int modifier_total, int delta_total, const char *actorid);

#endif
